<template>
  <el-row :gutter="20" class="mb-5">
    <el-col :span="6" :sm="6" :xs="12" :offset="0" v-for="item in 4" :key="item" v-if="loading">
      <el-card shadow="hover">
        <el-skeleton style="width: 100px" animated loading>
          <template #template>
            <div slot="header" class="card-header">
              <el-skeleton-item variant="p" style="width: 50%" />
              <el-skeleton-item variant="p" style="width: 10%" />
            </div>
            <div class="text-3xl font-bold text-gray-500 pt-5">
              <el-skeleton-item variant="p" style="width: 80%" />
            </div>
          </template>
        </el-skeleton>
      </el-card>
    </el-col>

    <el-col :span="6" :offset="0" v-for="(item, index) in list" :key="index" v-else>
      <el-card shadow="never">
        <div class="flex items-center">
          <el-icon :size="20" :class="item.color" class=" text-white rounded-full el-icon"
            style="width:40px; height: 40px;">
            <user v-if="index == 0" />
            <shopping-cart v-if="index == 1" />
            <price-tag v-if="index == 2" />
            <timer v-if="index == 3" />
          </el-icon>
          <div class="ml-3">
            <h2 class="text-lg font-bold">{{ item.value }}</h2>
            <small class="text-gray-400 text-xs">{{ item.label }}</small>
          </div>
        </div>
      </el-card>
    </el-col>
  </el-row>
</template>  

<script setup>
  import { ref } from 'vue'
  import { getAgentStratisticsApi } from '@/api/distribution.js'

  const loading = ref(false)
  const list = ref([])
  loading.value = true
  getAgentStratisticsApi()
    .then(res => {
      console.log("🚀 ~ res:", res)
      list.value = res.panels
    })
    .finally(() => loading.value = false)
</script>

<style scoped>
</style>
